package cn.digger.md2pdf.util;

import org.xhtmlrenderer.pdf.ITextRenderer;

import java.io.OutputStream;

public class Html2Pdf {

    public static void convertHtml2Pdf(String html, OutputStream outputStream) {
        ITextRenderer renderer = new ITextRenderer();
        renderer.setDocumentFromString(html);
        renderer.layout();

        try {
            renderer.createPDF(outputStream);
        } catch (Exception e) {
            throw new RuntimeException(e);
        }
    }
}
